import datetime
import pandas as pd
import backtrader as bt
import datetime


class MyStrategy(bt.Strategy):pass


cerebro = bt.Cerebro()

# add Data
# dataframe = pd.read_csv("bitmex_data.csv")
# dataframe['open_time'] = pd.to_datetime(dataframe['open_time'])
# dataframe.set_index('open_time', inplace=True)
# dataframe['openinterst'] = 0 # 换手率
# brf_hours = bt.feeds.PandasData(
#     dataname=dataframe,
#     fromdate=datetime.datetime(2020,10,19,4,24,00),
#     todate=datetime.datetime(2020,10,19,12,43,00)
# )

brf_ = bt.feeds.GenericCSVData(
    dataname="bitmex_data.csv",
    nullvalue=0.0,
    dtformat=('%Y-%m-%d %H:%M:%S'),
    datetime=0,
    high=2,
    low=3,
    open=1,
    close=4,
    volume=5,
    openinterest=-1
)


cerebro.adddata(brf_)
cerebro.addstrategy(MyStrategy)
cerebro.run()
cerebro.plot(style='candle')
